package org.cargloss.cp.controller.modul.banner;

import org.cargloss.cp.model.Banner;

import util.hibernate.DAO;

import com.opensymphony.xwork2.ActionSupport;

public class ActionCrud extends ActionSupport {
	private static final long serialVersionUID = -5933849517817526086L;
	private String id;
	private String fileName;
	private String toUrl;
	private String description;
	private int orderBy;

	public String insert() {
		DAO<Integer> dao = new DAO<Integer>();
		Banner object = new Banner();

		object.setFileName(getFileName());
		object.setOrderBy(getOrderBy());
		object.setToUrl(getToUrl());
		object.setDescription(getDescription());
		dao.insert(object);
		dao.close();
		return "empty";
	}

	public String update() {
		DAO<Integer> dao = new DAO<Integer>();

		Banner object = (Banner) dao.find(Banner.class,
				Integer.valueOf(getId()));

		object.setFileName(getFileName());
		object.setOrderBy(getOrderBy());
		object.setToUrl(getToUrl());
		object.setDescription(getDescription());
		dao.update(object);
		dao.close();
		return "empty";
	}

	public String delete() {
		DAO<Integer> dao = new DAO<Integer>();
		Banner delete = (Banner) dao.find(Banner.class,
				Integer.valueOf(getId()));

		dao.delete(delete);
		dao.close();
		return "empty";
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getToUrl() {
		return toUrl;
	}

	public void setToUrl(String toUrl) {
		this.toUrl = toUrl;
	}

	public int getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(int orderBy) {
		this.orderBy = orderBy;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}
